/**
  ******************************************************************************
  * @file    sym32l010_startkit_board.h
  * @author  AE Team
  * @version 1.0.3
  * @date    2024-05-28
  * @brief   Header file of sym32l010 startkit board support package.
  *
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2024 SIYIMicro.
  * All rights reserved.</center></h2>
  *
  *
  ******************************************************************************
  */


/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SYM32L010_STARTKIT_BOARD_H
#define __SYM32L010_STARTKIT_BOARD_H

#ifdef __cplusplus
extern "C" {
#endif


/******************************************************************************/
/* Include files                                                              */
/******************************************************************************/
#include "sym32l010_hal_def.h"
#include "sym32l010_hal_sysctrl.h"
#include "sym32l010_hal_systick.h"
#include "sym32l010_hal_gpio.h"


/******************************************************************************/
/* Global type definitions                                                    */
/******************************************************************************/
typedef enum
{
    USER_PRESS                                    = 0U,
    NO_PRESS                                      = 1U
} Bsp_Key_TypeDef;

/******************************************************************************/
/* Global pre-processor symbols/macros ('#define')                            */
/******************************************************************************/

//StartKit硬件资源配置：

/********************* 配置LED端口信息 ****************************************/
#define BSP_LED_PIN                              GPIO_PIN_3
#define BSP_LED_PORT                             SYM_GPIOA
#define BSP_LED_PERIPH_CLK_ENABLE()              HAL_SYSCTRL_GPIOA_CLK_ENABLE()
#define BSP_LED_PERIPH_CLK_DISABLE()             HAL_SYSCTRL_GPIOA_CLK_DISABLE()
#define BSP_LED_SETHIGH()                        PA03_SETHIGH()
#define BSP_LED_SETLOW()                         PA03_SETLOW()
#define BSP_LED_TOG()                            PA03_TOG()


/******************* 配置用户按键端口信息 *************************************/
#define BSP_KEY_PIN                              GPIO_PIN_4
#define BSP_KEY_PORT                             SYM_GPIOB
#define BSP_KEY_PERIPH_CLK_ENABLE()              HAL_SYSCTRL_GPIOB_CLK_ENABLE()
#define BSP_KEY_PERIPH_CLK_DISABLE()             HAL_SYSCTRL_GPIOB_CLK_DISABLE()
#define BSP_KEY_GETVALUE()                       PB04_GETVALUE()
#define BSP_KEY_IRQn                             GPIOB_IRQn


/******************* 配置电位器端口信息 ***************************************/
#define BSP_RHEOSTAT_PIN                         GPIO_PIN_6
#define BSP_RHEOSTAT_PORT                        SYM_GPIOA
#define BSP_RHEOSTAT_PERIPH_CLK_ENABLE()         HAL_SYSCTRL_GPIOA_CLK_ENABLE()
#define BSP_RHEOSTAT_PERIPH_CLK_DISABLE()        HAL_SYSCTRL_GPIOA_CLK_DISABLE()


/******************* 配置红外端口信息 *****************************************/
#define BSP_IR_PIN                               GPIO_PIN_3
#define BSP_IR_PORT                              SYM_GPIOA
#define BSP_IR_PERIPH_CLK_ENABLE()               HAL_SYSCTRL_GPIOA_CLK_ENABLE()
#define BSP_IR_PERIPH_CLK_DISABLE()              HAL_SYSCTRL_GPIOA_CLK_DISABLE()


/******************* 配置用于Printf的端口和外设和信息 *************************/
#define BSP_UART_TXD_PIN                         GPIO_PIN_2
#define BSP_UART_TXD_PORT                        SYM_GPIOB
#define BSP_UART_TXD_AF                          AFx_UART2TXD_PB02
#define BSP_UART_TXD_PORT_PERIPH_CLK_ENABLE()    HAL_SYSCTRL_GPIOB_CLK_ENABLE()
#define BSP_UART_TXD_PORT_PERIPH_CLK_DISABLE()   HAL_SYSCTRL_GPIOB_CLK_DISABLE()

#define BSP_UART_RXD_PIN                         GPIO_PIN_4
#define BSP_UART_RXD_PORT                        SYM_GPIOA
#define BSP_UART_RXD_IRQn                        GPIOA_IRQn
#define BSP_UART_RXD_AF                          AFx_UART2RXD_PA04
#define BSP_UART_RXD_PORT_PERIPH_CLK_ENABLE()    HAL_SYSCTRL_GPIOA_CLK_ENABLE()
#define BSP_UART_RXD_PORT_PERIPH_CLK_DISABLE()   HAL_SYSCTRL_GPIOA_CLK_DISABLE()

#define BSP_UART                                 SYM_UART2
#define BSP_UART_IRQn                            UART2_IRQn
#define BSP_UART_PERIPH_CLK_ENABLE()             HAL_SYSCTRL_UART2_CLK_ENABLE()
#define BSP_UART_PERIPH_CLK_DISABLE()            HAL_SYSCTRL_UART2_CLK_DISABLE()
#define BSP_UART_PERIPH_RST_ENABLE()             HAL_SYSCTRL_UART2_RST_ENABLE()
#define BSP_UART_PERIPH_RST_DISABLE()            HAL_SYSCTRL_UART2_RST_DISABLE()


/******************************************************************************/
/* Global macro function                                                      */
/******************************************************************************/


/******************************************************************************/
/* Exported variables ('extern', definition in C source)                      */
/******************************************************************************/


/******************************************************************************/
/* Global function prototypes ('extern', definition in C source)              */
/******************************************************************************/
extern void    Bsp_Uart_Init(uint32_t pclkFreq, uint32_t baudRate);

extern void    Bsp_Key_Init(void);
extern uint8_t Bsp_Read_Key(void);

extern void    Bsp_Led_Init(void);
extern void    Bsp_Led_On(void);
extern void    Bsp_Led_Off(void);
extern void    Bsp_Led_Tog(void);

extern void    Bsp_RheostatPort_Init(void);
extern void    Bsp_IrPort_Init(void);

extern void    Bsp_Init(uint32_t ClkFreq);

#ifdef __cplusplus
}
#endif

#endif /* __SYM32L010_STARTKIT_BOARD_H */


/************************ (C) COPYRIGHT SIYIMicro *****END OF FILE*************/
